package cn.wmlce.wminspringboot;

import cn.wmlce.wminspringboot.config.AuthorSettings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication//是SpringBoot项目的核心注解，主要目的是开启自动配置
public class WminspringbootApplication {

    @Value("${book.author}")
    private String bookAuthor;

    @Value("${book.name}")
    private String bookName;

    @Autowired
    private AuthorSettings authorSettings;

    @RequestMapping("/")
    public String index(){
        return "book name is:"+bookName+" and book author is:"+bookAuthor;
    }


    @RequestMapping("/index2")
    public String index2(){
        return "author name is:"+authorSettings.getName()+" and author age is:"+authorSettings.getAge();
    }

    public static void main(String[] args) {
//        SpringApplication.run(WminspringbootApplication.class, args);
        SpringApplication app = new SpringApplication(WminspringbootApplication.class);
        app.run(args);
    }
}
